package com.spring.commonality.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.spring.base.AdminBaseController;
import com.spring.commonality.service.IGeneralCharsService;
import com.spring.doctor.dto.RegionDocDto;
import com.spring.doctor.service.IDocDoctorInfoService;
import com.spring.trade.service.ITradeOrderInfoService;

@Controller
@RequestMapping(value = "admin/general")
public class GeneralInfoController extends AdminBaseController {

	@Autowired
	private IDocDoctorInfoService docDoctorInfoService;
/*	@Autowired
	private IPatientCustomerService patientCustomerService;*/
	@Autowired
	private ITradeOrderInfoService tradeOrderInfoService;

	@Autowired
	private IGeneralCharsService generalCharsService;

	@RequestMapping(value = "/getGeneralInfo")
	public String getGeneralInfo(Model model) {
		try {
			// null 总数 0 未认证 1已认证
			int totalNum = docDoctorInfoService.selectTotalDoctor(null);
			int totalAuthNum = docDoctorInfoService.selectTotalDoctor(0);
//			Integer totalPatientNum = patientCustomerService.getCustomerNumber(null);// 患者总数
			Integer totalPatientNum = 100;
//			int orderCount = tradeOrderInfoService.getPayOrderCount();
			int orderCount = 200;
			model.addAttribute("totalAuthDoctor", totalNum);
			model.addAttribute("totalNotAuthDoctor", totalAuthNum);
			model.addAttribute("totalPatient",totalPatientNum);
			model.addAttribute("totalPayorderCount", orderCount);
		} catch (Exception e) {
			logger.error(e.fillInStackTrace());
		}
		return "general/general_info";
	}

	@RequestMapping(value = "/getFeedBackPieChartData")
	@ResponseBody
	public Map<String, Object> getFeedBackPieChartData() {
		Map<String, Object> map = generalCharsService.getFeedBackPieChartData();
		return map;
	}

	@RequestMapping(value = "/getRegionDocChartData")
	@ResponseBody
	public List getRegionDocChartData() {
		List<RegionDocDto> regionDocList = docDoctorInfoService.staticsDocRegion();
		return regionDocList;
	}

	/**
	 * 按天和月 查询订单统计
	 * 
	 * @param type
	 * @return
	 */
	@RequestMapping(value = "/getOrderFormChartData")
	@ResponseBody
	public Map<String, Object> getOrderFormChartData(String type) {
		Map<String, Object> map = null;
		if (type.equals("day")) {
			map = generalCharsService.getOrderFormChartDate(type);
		} else if (type.equals("Month")) {
			map = generalCharsService.getOrderFormChartDate(type);
		} else if (type.equals("Weeks")) {
			map = generalCharsService.findOrderFormChartWeeksData();
		}
		return map;
	}
}
